import {EventEmitter} from "@angular/core";
import {ResponseMsgModel} from "../shared/model/response-msg-model";
/**
 * This class is the supClass of validator for user register
 * Created by wubin on 2016-11-26.
 */
export abstract class VerifyCommon {
    /**
     * subClass must implement this method for VerifyCommon to provide
     * EventEmitter
     */
    abstract getResponseEmitter(): EventEmitter<ResponseMsgModel>;

    /**
     * This method is used to return verified result to component.
     * @param result
     * @param msg
     */
    protected responseComponent(result: boolean, msg: string) {
        let responseResult: ResponseMsgModel = new ResponseMsgModel(result, msg);
        this.getResponseEmitter().emit(responseResult);
    }

    protected restoreTargetInput() {
        this.getResponseEmitter().emit(null);
    }
}